﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMI.NET.CIM
{
    /// <summary>
    /// The CIM_PhysicalElement subclasses define any component of a system that has a distinct physical identity. Instances of this class can be defined in terms of labels that can be physically attached to the object. All processes, files, and logical devices are not considered to be physical elements. For example, it is not possible to attach a label to a modem; it is only possible to attach a label to the card that implements the modem. The same card could also implement a LAN adapter.
    /// Tangible managed system elements (usually hardware items) have a physical manifestation. A managed system element is not necessarily a discrete component. For example, it is possible for a single card (a type of physical element) to host more than one logical device. The card would be represented by a single physical element associated with multiple logical devices. 
    /// </summary>
    public class CIM_PhysicalElement : CIM_ManagedSystemElement
    {

        private string _CreationClassName;
        private string _Manufacturer;
        private string _Model;
        private string _OtherIdentifyingInfo;
        private string _PartNumber;
        private Nullable<Boolean> _PoweredOn;
        private string _SerialNumber;
        private string _SKU;
        private string _Tag;
        private string _Version;


        /// <summary>
        /// Name of the class or subclass used in the creation of an instance. When used with other key properties of the class, this property allows all instances of the class and its subclasses to be uniquely identified.
        /// </summary>
        public string CreationClassName { get { return _CreationClassName; } }

        /// <summary>
        /// Name of the organization responsible for producing the physical element.
        /// </summary>
        public string Manufacturer { get { return _Manufacturer; } }

        /// <summary>
        /// Name by which the physical element is generally known.
        /// </summary>
        public string Model { get { return _Model; } }

        /// <summary>
        /// Additional data, beyond asset tag information, that can be used to identify a physical element. One example is bar-code data that is associated with an element, which also has an asset tag. Note that if only bar-code data is available, and is unique and able to be used as an element key, this property would be null and the bar-code data would be used as the class key in the Tag property. 
        /// </summary>
        public string OtherIdentifyingInfo { get { return _OtherIdentifyingInfo; } }

        /// <summary>
        /// Part number assigned by the organization responsible for producing or manufacturing the physical element.
        /// </summary>
        public string PartNumber { get { return _PartNumber; } }

        /// <summary>
        /// If TRUE, the physical element is powered on. Otherwise, it is currently off.
        /// </summary>
        public Nullable<Boolean> PoweredOn { get { return _PoweredOn; } }

        /// <summary>
        /// Manufacturer-allocated number used to identify the physical element.
        /// </summary>
        public string SerialNumber { get { return _SerialNumber; } }

        /// <summary>
        /// Stock-keeping unit number for this physical element.
        /// </summary>
        public string SKU { get { return _SKU; } }

        /// <summary>
        /// Arbitrary string that uniquely identifies the physical element and serves as the element's key. This property can contain information, such as asset tag or serial number data. The key for CIM_PhysicalElement is placed very high in the object hierarchy to independently identify the hardware or entity, regardless of physical placement in (or on) cabinets, adapters, and so on. For example, a removable component that can be hot-swapped can be taken from its containing (scoping) package and be temporarily unused. The object still continues to exist and can even be inserted into a different scoping container. The key for a physical element is an arbitrary string that is defined independently of placement or location-oriented hierarchy.
        /// </summary>
        public string Tag { get { return _Tag; } }

        /// <summary>
        /// String that indicates the version of the physical element.
        /// </summary>
        public string Version { get { return _Version; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public CIM_PhysicalElement(ManagementBaseObject mbo)
            : base(mbo)
        {
            _CreationClassName = mbo.GetStringValue("CreationClassName");
            _Manufacturer = mbo.GetStringValue("Manufacturer");
            _Model = mbo.GetStringValue("Model");
            _OtherIdentifyingInfo = mbo.GetStringValue("OtherIdentifyingInfo");
            _PartNumber = mbo.GetStringValue("PartNumber");
            _PoweredOn = mbo.GetBoolValue("PoweredOn");
            _SerialNumber = mbo.GetStringValue("SerialNumber");
            _SKU = mbo.GetStringValue("SKU");
            _Tag = mbo.GetStringValue("Tag");
            _Version = mbo.GetStringValue("Version");
        }

    }
}
